package com.yaowk.service.mall.clothing.service.impl;

import com.yaowk.api.mall.clothing.model.Commission;
import com.yaowk.api.mall.clothing.service.ICommissionService;
import com.yaowk.service.common.BaseRepository;
import com.yaowk.service.common.BaseServiceImpl;
import com.yaowk.service.mall.clothing.dao.CommissionDao;
import com.yaowk.service.mall.clothing.entity.CmCommission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CommissionServiceImpl extends BaseServiceImpl<Commission, CmCommission, Integer> implements ICommissionService {

    @Autowired
    private CommissionDao dao;

    @Override
    protected BaseRepository getDao() {
        return dao;
    }

    @Override
    protected CmCommission model2Entity(Commission model) {
        CmCommission cmCommission = null;
        if (isNotEmpty(model)) {
            cmCommission = new CmCommission();
            cmCommission.setComputeType(model.getComputeType());
            cmCommission.setComputeValue(model.getComputeValue());
            cmCommission.setName(model.getName());
            cmCommission.setId(model.getId());
        }
        return cmCommission;
    }

    @Override
    protected Commission entity2model(CmCommission entity) {
        Commission commission = null;
        if (isNotEmpty(entity)) {
            commission = new Commission();
            commission.setComputeType(entity.getComputeType());
            commission.setComputeValue(entity.getComputeValue());
            commission.setName(entity.getName());
            commission.setId(entity.getId());
        }
        return commission;
    }
}
